<?php

namespace App\Http\Requests\Api;

class MemberCardOrdersRequest extends FormRequest
{

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
                {
                    return [
                        'id' => ['required', 'exists:shop_user,id'],
                    ];
                }
            case 'POST':
                {
                    return [
                        'code' => ['required'],
                        'member_card_id' => ['required', 'exists:member_cards,id'],
                    ];
                }
        }
    }

    public function messages()
    {
        return [
            'code.required' => 'code不能为空',
            'member_card_id.required' => '会员卡ID不能为空',
            'member_card_id.exists' => '会员卡ID不存在',
        ];
    }
}
